package cn.demo.act.service.impl;

import java.time.LocalDateTime;
import java.util.List;
import com.mybatisflex.core.paginate.Page;
import cn.demo.common.core.page.PageQuery;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import cn.demo.act.mapper.ActRegisterMapper;
import cn.demo.act.domain.ActRegister;
import cn.demo.act.service.IActRegisterService;

/**
 * 活动报名管理Service业务层处理
 *
 * @author xtjun
 * @date 2024-06-06
 */
@Service
public class ActRegisterServiceImpl extends ServiceImpl<ActRegisterMapper, ActRegister> implements IActRegisterService {
    @Resource
    private ActRegisterMapper actRegisterMapper;
    /**
     * 查询活动报名管理
     *
     * @param id 活动报名管理主键
     * @return 活动报名管理
     */
    @Override
    public ActRegister selectActRegisterById(String id) {
        return actRegisterMapper.selectOneById(id);
    }

    /**
     * 查询活动报名管理列表
     *
     * @param actRegister 活动报名管理
     * @return 活动报名管理
     */
    @Override
    public Page<ActRegister> selectActRegisterPage(ActRegister actRegister, PageQuery pageQuery) {
        return actRegisterMapper.paginate(pageQuery.build(), QueryWrapper.create(actRegister,ActRegister.operators));
    }
    @Override
    public List<ActRegister> selectActRegisterList(ActRegister actRegister) {
        return actRegisterMapper.selectListByQuery(QueryWrapper.create(actRegister,ActRegister.operators));
    }

    /**
     * 新增活动报名管理
     *
     * @param actRegister 活动报名管理
     * @return 结果
     */
    @Override
    public int insertActRegister(ActRegister actRegister) {
        actRegister.setApplyTime(LocalDateTime.now());
        return actRegisterMapper.insert(actRegister);
    }

    /**
     * 修改活动报名管理
     *
     * @param actRegister 活动报名管理
     * @return 结果
     */
    @Override
    public int updateActRegister(ActRegister actRegister) {
        return actRegisterMapper.update(actRegister);
    }

    /**
     * 批量删除活动报名管理
     *
     * @param ids 需要删除的活动报名管理主键
     * @return 结果
     */
    @Override
    public int deleteActRegisterByIds(List<String> ids) {
        return actRegisterMapper.deleteBatchByIds(ids);
    }

    /**
     * 删除活动报名管理信息
     *
     * @param id 活动报名管理主键
     * @return 结果
     */
    @Override
    public int deleteActRegisterById(String id) {
        return actRegisterMapper.deleteById(id);
    }
}
